
import java.util.Scanner;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        char[] s = in.next().toCharArray();
        int x = in.nextInt();
        int begin = 0; // 标记结果的起始位置
        int maxCount = 0; // 统计以前窗⼝内 C + G 的最⼤值
        int left = 0, right = 0, n = s.length;
        int count = 0; // 统计窗⼝内 C + G
        while(right < n) {
          if(s[right] == 'C' || s[right] == 'G')
              count++;
          while(right - left + 1 > x) {
            if(s[left] == 'C' || s[left] == 'G') count--; left++;
          }
          if(right - left + 1 == x) {
            if(count > maxCount) {
                begin = left; maxCount = count; }
            }
            right++;
          }
        for(int i = begin; i < begin + x; i++) {
        System.out.print(s[i]);
       }
    }
}

